spb/cancerindex
Public
TypeScript 97.2%
SQL 1.5%
CSS 0.6%
JavaScript 0.5%
1import { ogImage, OG_SIZE, OG_CONTENT_TYPE } from '@/lib/og';2import { getTrialByNct } from '@/lib/queries/trials';3import { fmtInt, humanize, phaseLabel } from '@/lib/format';45export const alt = 'CancerIndex clinical trial page';6export const size = OG_SIZE;7export const contentType = OG_CONTENT_TYPE;8export const revalidate = 3600;910export default async function Image({ params }: { params: Promise<{ nct: string }> }) {11 const { nct } = await params;12 const t = await getTrialByNct(nct);13 if (!t) return ogImage({ kicker: 'Clinical trial', title: 'Study not found', subtitle: nct });14 const facts = [15 t.phases.length ? { label: 'phase', value: t.phases.map(phaseLabel).join(' / ') } : null,16 t.overall_status ? { label: 'status', value: humanize(t.overall_status) } : null,17 t.enrollment_count != null ? { label: 'enrollment (n)', value: fmtInt(t.enrollment_count) } : null,18 t.countries.length ? { label: 'countries', value: fmtInt(t.countries.length) } : null,19 ].filter((f): f is { label: string; value: string } => !!f);20 return ogImage({21 kicker: `Clinical trial · ${t.nct_id}${t.study_type ? ` · ${humanize(t.study_type)}` : ''}`,22 title: t.brief_title,23 subtitle: t.lead_sponsor ? `Lead sponsor: ${t.lead_sponsor}${t.lead_sponsor_class ? ` (${humanize(t.lead_sponsor_class)})` : ''}` : null,24 facts,25 sourcesNote: 'ClinicalTrials.gov · status and phase as posted',26 });27}28